/*************************************************************************
> File Name: 8.c
> Author: hzy
> Created Time: 2023-07-24 19:38:56
> Description: 8、有一个3×4的矩阵，要求输出其中值最大的元素的值，以及它的行号和列号。
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char const *argv[])
{
    int a[3][4] = {{65, 2, 3, 4}, {5, 22, 88, 8}, {99, 12, 11, 25}};

    int i = 0, j = 0, row = 0, col = 0;
    int max = 0;

    int *p = &a[0][0];

    for (i = 0; i < 3; i++)
    {
        for (j = 0; j < 4; j++)
        {
            if (*(p + i * 4 + j) > max)
            {
                max = *(p + i * 4 + j);
                row = i;
                col = j;
            }
        }
    }

    printf("max: a[%d][%d] = %d\n", row, col, *(p+row*4+col));

    return 0;
}